package com.sync.utils.project.wechat.controller;

import com.sync.utils.common.enums.ResultCodeEnum;
import com.sync.utils.framework.result.R;
import com.sync.utils.project.wechat.pojo.AccessTokenReq;
import com.sync.utils.project.wechat.pojo.AccessTokenRes;
import com.sync.utils.project.wechat.service.AuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信登录接口
 *
 * @Author YWF
 * @Date 2025/5/6 11:35
 */
@Slf4j
@RestController
@RequestMapping("/wx/")
public class AuthController {

    @Autowired
    private AuthService authService;

    @RequestMapping(value = "getAccessToken", method = RequestMethod.POST)
    public R<AccessTokenRes> getRemoteGasMonthBillList(@RequestBody AccessTokenReq request) {
        AccessTokenRes accessToken = authService.getAccessToken(request);
        if (!ObjectUtils.isEmpty(accessToken)) {
            return R.ok().data(accessToken);
        }
        return R.setResult(ResultCodeEnum.RESULT_NULL);
    }

}
